// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({ env: cloud.DYNAMIC_CURRENT_ENV }) // 使用当前云环境

// 云函数入口函数
exports.main = async (event, context) => {
  console.log(event.u_id);
  return cloud.callFunction({
    name: "model_student",
    data: {
      op: "add",
      u_id: event.u_id,
      i_id: event.i_id,
      name: event.name,
      sex: event.sex,
      height: event.height,
      weight: event.weight,
      grade: event.grade,
      class: event.class,
      special: event.special,
      bust: event.bust,
      waist: event.waist,
      hip: event.hip,
      default: event.default
    }
  }).then(res => {
    var _id = res.result._id;
    console.log(_id);
    return cloud.callFunction({//添加后再查询出来
      name: "model_student",
      data: {
        op: "select",
        key: "_id",
        value: _id
      }
    }).then(res => {
      return res.result.data;
    })
  })
}